package com.xhui.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author XHui
 * @date 2022/11/06 02:18:40
 * Version: 1.0.0
 * Description: 配置mybatis-plus的拦截器，核心目的是为了动态的拼写SQL语句
 */
@Configuration // 声明为此类为一个配置类
public class MyBatisPlusConfig {

    @Bean // 声明此方法的返回值对象由Spring创建
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //添加一个内部拦截器
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        return interceptor;
    }


}
